home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / raid / devRaid.h < prev    next >
C/C++ Source or Header  |  1991-06-27  |  5KB  |  183 lines

  1. /* 
  2.  * devRaid.h --
  3.  *
  4.  *    Declarations for RAID device drivers.
  5.  *
  6.  * Copyright 1989 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  *
  15.  * $Header: /sprite/src/kernel/raid/RCS/devRaid.h,v 1.10 90/10/12 14:01:20 eklee Exp $ SPRITE (Berkeley)
  16.  */
  17.  
  18. #ifndef _DEVRAID
  19. #define _DEVRAID
  20.  
  21. #include "sprite.h"
  22. #include "sync.h"
  23. #include "fs.h"
  24. #include "devBlockDevice.h"
  25. #include "devRaidDisk.h"
  26. #include "devRaidLog.h"
  27. #include "bitvec.h"
  28.  
  29. #ifndef MIN
  30. #define MIN(a,b) ( (a) < (b) ? (a) : (b) )
  31. #endif  MIN
  32.  
  33. #ifndef MAX
  34. #define MAX(a,b) ( (a) > (b) ? (a) : (b) )
  35. #endif  MAX
  36.  
  37. #define BITS_PER_ADDR            32
  38. #define RAID_MAX_XFER_SIZE        (1<<30)
  39. #ifdef TESTING
  40. #define RAID_ROOT_CONFIG_FILE_NAME    "RAID"
  41. #else
  42. #define RAID_ROOT_CONFIG_FILE_NAME    "/ra/raid/RAID"
  43. #endif TESTING
  44.  
  45. /*
  46.  * Data structure each RAID device.
  47.  *
  48.  * RAID_INVALID    ==> Array has not been configured.
  49.  * RAID_ATTACHED==> Array attached but not configured.
  50.  * RAID_VALID    ==> Array is configured and ready to service requests.
  51.  */
  52. typedef enum { RAID_INVALID, RAID_ATTACHED, RAID_VALID } RaidState;
  53.  
  54. typedef struct Raid {
  55.     RaidState         state;        /* must be first field */
  56.     Sync_Semaphore     mutex;        /* must be second field */
  57.     Sync_Condition     waitExclusive;
  58.     Sync_Condition     waitNonExclusive;
  59.     int             numReqInSys; /* -1 => exclusive access */
  60.     int             numWaitExclusive; /* number waiting for */
  61.                       /* exclusive access. */
  62.     int             numStripeLocked;
  63.  
  64.     Fs_Device        *devicePtr; /* Device corresponding to this raid. */
  65.     int             numCol;
  66.     int             numRow;
  67.     RaidDisk          ***disk;        /* 2D array of disks (column major) */
  68.  
  69.     DevBlockDeviceHandle *logHandlePtr;
  70.     Fs_Device         logDev;
  71.     int             logDevOffset;
  72.     RaidLog         log;
  73.  
  74.     unsigned         numSector;
  75.     int              numStripe;
  76.     int             dataSectorsPerStripe;
  77.     int             dataStripeUnitsPerDisk;
  78.     int              sectorsPerDisk;
  79.     int              bytesPerStripeUnit;
  80.     int              dataBytesPerStripe;
  81.  
  82.     int              numDataCol;
  83.     int              logBytesPerSector;
  84.     int              sectorsPerStripeUnit;
  85.     int              rowsPerGroup;
  86.     int              stripeUnitsPerDisk;
  87.     int              groupsPerArray;
  88.     char         parityConfig;
  89. } Raid;
  90.  
  91. /*
  92.  * RaidHandle.
  93.  */
  94. typedef struct RaidHandle {        /* Subclass of DevBlockDeviceHandle. */
  95.     DevBlockDeviceHandle blockHandle;    /* Must be FIRST field. */
  96.     Fs_Device        *devPtr;    /* Device corresponding to handle */
  97.     Raid        *raidPtr;
  98. } RaidHandle;
  99.  
  100. /*
  101.  * RaidBlockRequest
  102.  *
  103.  * REQ_INVALID    ==> the request is to a failed device
  104.  * REQ_FAILED    ==> an error code was returned by the device
  105.  * REQ_READY    ==> the request is ready to be issued
  106.  * REQ_COMPLETED==> the request has successfully completed
  107.  * REQ_PENDING     ==> the request has been issued and is waiting for completion
  108.  */
  109. typedef enum RaidBlockRequestState {    /* Subclass of DevBlockDeviceRequest */
  110.     REQ_INVALID, REQ_FAILED, REQ_READY, REQ_COMPLETED, REQ_PENDING
  111. } RaidBlockRequestState;
  112.  
  113. typedef struct RaidBlockRequest {
  114.     DevBlockDeviceRequest devReq;
  115.     RaidBlockRequestState state;
  116.     ReturnStatus      status;
  117.     Raid         *raidPtr;
  118.     int              col;
  119.     int              row;
  120.     RaidDisk         *diskPtr;
  121.     int              version;
  122. } RaidBlockRequest;
  123.  
  124. /*
  125.  * Raid Control structures for syncronizing/communicating with
  126.  * interrupt routines.
  127.  */
  128. typedef struct RaidIOControl {
  129.     Sync_Semaphore     mutex;
  130.     Raid        *raidPtr;
  131.     int             numIO;
  132.     void           (*doneProc)();
  133.     ClientData         clientData;
  134.     ReturnStatus     status;
  135.     int             amountTransferred;
  136.     int             numFailed;
  137.     RaidBlockRequest    *failedReqPtr;
  138. } RaidIOControl;
  139.  
  140. typedef struct RaidRequestControl {
  141.     RaidBlockRequest    *reqPtr;
  142.     int             numReq;
  143.     int             numFailed;
  144.     RaidBlockRequest    *failedReqPtr;
  145. } RaidRequestControl;
  146.  
  147. typedef struct RaidStripeIOControl {
  148.     Raid        *raidPtr;
  149.     int             operation;
  150.     unsigned         firstSector;
  151.     unsigned         nthSector;
  152.     Address         buffer;
  153.     void           (*doneProc)();
  154.     ClientData         clientData;
  155.     void           (*recoverProc)();
  156.     int             ctrlData;
  157.     RaidRequestControl    *reqControlPtr;
  158.     char        *parityBuf;
  159.     char        *readBuf;
  160.     int             rangeOff;
  161.     int             rangeLen;
  162. } RaidStripeIOControl;
  163.  
  164. typedef struct RaidReconstructionControl {
  165.     Raid        *raidPtr;
  166.     int             col;
  167.     int             row;
  168.     RaidDisk        *diskPtr;
  169.     int             stripeID;
  170.     int             numStripe;
  171.     void           (*doneProc)();
  172.     ClientData         clientData;
  173.     int             ctrlData;
  174.     RaidRequestControl    *reqControlPtr;
  175.     ReturnStatus     status;
  176.     char        *parityBuf;
  177.     char        *readBuf;
  178. } RaidReconstructionControl;
  179.  
  180. extern DevBlockDeviceHandle *DevRaidAttach _ARGS_((Fs_Device *devicePtr));
  181.  
  182. #endif _DEVRAID
  183.